// v-imagerror
import Vue from 'vue'
import img from '@/assets/common/head.jpg'
Vue.directive('fiximg', {
//   bind(el, binding, vnode) {},
  inserted(el, binding) {
    // 如果图片地址出现错误的话，运行该函数
    el.onerror = function() {
      el.src = img
    }
    // 如果图片地址为空，则用默认地址
    el.src = el.src || img
  }
//   update(el, binding, vnode, oldVnode) {},
//   componentUpdated(el, binding, vnode) {},
//   unbind(el, binding, vnode) {}
})

Vue.directive('fixPhoto', {
  //   bind(el, binding, vnode) {},
  inserted(el, binding) {
    el.onerror = function() {
      el.src = 'http://ihrm.itheima.net/static/img/bigUserHeader.fda3837f.png'
    }
    el.src = el.src || 'http://ihrm.itheima.net/static/img/bigUserHeader.fda3837f.png'
  }
  //   update(el, binding, vnode, oldVnode) {},
  //   componentUpdated(el, binding, vnode) {},
  //   unbind(el, binding, vnode) {}
})
